.class public final Lcom/burstly/lib/currency/UserAccountStorage;
.super Ljava/lang/Object;
.source "UserAccountStorage.java"


# static fields
.field private static final INITIAL_CACHE_CAPACITY:I = 0x4

.field private static final INSTANCE:Lcom/burstly/lib/currency/UserAccountStorage; = null

.field private static final LOCK:Ljava/util/concurrent/locks/Lock; = null

.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "CurrencyManager"

.field private static sCacheDir:Ljava/io/File;


# instance fields
.field private final mAccountCache:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Lcom/burstly/lib/currency/UserAccount;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 56
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/currency/UserAccountStorage;->LOG:Lcom/burstly/lib/util/LoggerExt;

    .line 66
    new-instance v0, Ljava/util/concurrent/locks/ReentrantLock;

    invoke-direct {v0}, Ljava/util/concurrent/locks/ReentrantLock;-><init>()V

    sput-object v0, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    .line 71
    new-instance v0, Lcom/burstly/lib/currency/UserAccountStorage;

    invoke-direct {v0}, Lcom/burstly/lib/currency/UserAccountStorage;-><init>()V

    sput-object v0, Lcom/burstly/lib/currency/UserAccountStorage;->INSTANCE:Lcom/burstly/lib/currency/UserAccountStorage;

    return-void
.end method

.method private constructor <init>()V
    .locals 2

    .prologue
    .line 86
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 76
    new-instance v0, Ljava/util/HashMap;

    const/4 v1, 0x4

    invoke-direct {v0, v1}, Ljava/util/HashMap;-><init>(I)V

    iput-object v0, p0, Lcom/burstly/lib/currency/UserAccountStorage;->mAccountCache:Ljava/util/Map;

    .line 87
    return-void
.end method

.method private static createAccount(Lcom/burstly/lib/currency/AccountInfo;)Lcom/burstly/lib/currency/UserAccount;
    .locals 4
    .parameter "accountInfo"

    .prologue
    .line 162
    new-instance v1, Lcom/burstly/lib/currency/UserAccount;

    invoke-direct {v1}, Lcom/burstly/lib/currency/UserAccount;-><init>()V

    .line 163
    .local v1, newAccount:Lcom/burstly/lib/currency/UserAccount;
    invoke-virtual {p0}, Lcom/burstly/lib/currency/AccountInfo;->getPubId()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v3}, Lcom/burstly/lib/currency/UserAccount;->setPubId(Ljava/lang/String;)V

    .line 164
    invoke-virtual {p0}, Lcom/burstly/lib/currency/AccountInfo;->getUserId()Ljava/lang/String;

    move-result-object v2

    .line 165
    .local v2, userId:Ljava/lang/String;
    invoke-virtual {v1, v2}, Lcom/burstly/lib/currency/UserAccount;->setUserId(Ljava/lang/String;)V

    .line 166
    invoke-static {}, Lcom/burstly/lib/util/Utils;->getDeviceId()Ljava/lang/String;

    move-result-object v0

    .line 167
    .local v0, deviceId:Ljava/lang/String;
    invoke-virtual {v1, v0}, Lcom/burstly/lib/currency/UserAccount;->setDeviceId(Ljava/lang/String;)V

    .line 168
    invoke-virtual {v0, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    invoke-virtual {v1, v3}, Lcom/burstly/lib/currency/UserAccount;->setUserIdDeviceIdBased(Z)V

    .line 169
    return-object v1
.end method

.method private static createFileName(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 2
    .parameter "userId"
    .parameter "pubId"

    .prologue
    .line 266
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 267
    .local v0, totalHash:Ljava/lang/String;
    invoke-virtual {v0}, Ljava/lang/String;->hashCode()I

    move-result v1

    invoke-static {v1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/burstly/lib/util/Utils;->sha1(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    return-object v1
.end method

.method public static getInstance()Lcom/burstly/lib/currency/UserAccountStorage;
    .locals 1

    .prologue
    .line 95
    sget-object v0, Lcom/burstly/lib/currency/UserAccountStorage;->INSTANCE:Lcom/burstly/lib/currency/UserAccountStorage;

    return-object v0
.end method

.method static initCacheDirectory(Landroid/content/Context;)V
    .locals 2
    .parameter "applicationContext"

    .prologue
    .line 304
    const-string v0, "cm"

    const/4 v1, 0x0

    invoke-virtual {p0, v0, v1}, Landroid/content/Context;->getDir(Ljava/lang/String;I)Ljava/io/File;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/currency/UserAccountStorage;->sCacheDir:Ljava/io/File;

    .line 305
    return-void
.end method

.method private loadAccount(Lcom/burstly/lib/currency/AccountInfo;)Lcom/burstly/lib/currency/UserAccount;
    .locals 4
    .parameter "accountInfo"

    .prologue
    .line 214
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getUserId()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getPubId()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Lcom/burstly/lib/currency/UserAccountStorage;->createFileName(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 216
    .local v1, fileName:Ljava/lang/String;
    :try_start_0
    sget-object v2, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v2}, Ljava/util/concurrent/locks/Lock;->lock()V

    .line 217
    new-instance v0, Ljava/io/File;

    sget-object v2, Lcom/burstly/lib/currency/UserAccountStorage;->sCacheDir:Ljava/io/File;

    invoke-direct {v0, v2, v1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 218
    .local v0, file:Ljava/io/File;
    invoke-direct {p0, v0}, Lcom/burstly/lib/currency/UserAccountStorage;->readFile(Ljava/io/File;)Lcom/burstly/lib/currency/UserAccount;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result-object v2

    .line 221
    sget-object v3, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v3}, Ljava/util/concurrent/locks/Lock;->unlock()V

    return-object v2

    .end local v0           #file:Ljava/io/File;
    :catchall_0
    move-exception v2

    sget-object v3, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v3}, Ljava/util/concurrent/locks/Lock;->unlock()V

    throw v2
.end method

.method private readFile(Ljava/io/File;)Lcom/burstly/lib/currency/UserAccount;
    .locals 14
    .parameter "cachedAccount"

    .prologue
    .line 232
    const/4 v1, 0x0

    .line 233
    .local v1, cached:Ljava/io/InputStream;
    const/4 v5, 0x0

    .line 235
    .local v5, objis:Ljava/io/ObjectInputStream;
    :try_start_0
    new-instance v2, Ljava/io/BufferedInputStream;

    new-instance v9, Ljava/io/FileInputStream;

    invoke-direct {v9, p1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    invoke-direct {v2, v9}, Ljava/io/BufferedInputStream;-><init>(Ljava/io/InputStream;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/io/FileNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_2

    .line 236
    .end local v1           #cached:Ljava/io/InputStream;
    .local v2, cached:Ljava/io/InputStream;
    :try_start_1
    new-instance v6, Ljava/io/ObjectInputStream;

    invoke-direct {v6, v2}, Ljava/io/ObjectInputStream;-><init>(Ljava/io/InputStream;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1
    .catch Ljava/io/FileNotFoundException; {:try_start_1 .. :try_end_1} :catch_7
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_5
    .catch Ljava/lang/ClassNotFoundException; {:try_start_1 .. :try_end_1} :catch_3

    .line 237
    .end local v5           #objis:Ljava/io/ObjectInputStream;
    .local v6, objis:Ljava/io/ObjectInputStream;
    :try_start_2
    invoke-virtual {v6}, Ljava/io/ObjectInputStream;->readObject()Ljava/lang/Object;

    move-result-object v7

    .line 238
    .local v7, userAccount:Ljava/lang/Object;
    sget-object v9, Lcom/burstly/lib/currency/UserAccountStorage;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "CurrencyManager"

    const-string v11, "User account: {0} has been loaded from file."

    const/4 v12, 0x1

    new-array v12, v12, [Ljava/lang/Object;

    const/4 v13, 0x0

    aput-object v7, v12, v13

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 239
    move-object v0, v7

    check-cast v0, Lcom/burstly/lib/currency/UserAccount;

    move-object v8, v0

    .line 240
    .local v8, usrAccount:Lcom/burstly/lib/currency/UserAccount;
    invoke-virtual {p1}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Lcom/burstly/lib/currency/UserAccount;->setCacheFilename(Ljava/lang/String;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_2
    .catch Ljava/io/FileNotFoundException; {:try_start_2 .. :try_end_2} :catch_8
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_6
    .catch Ljava/lang/ClassNotFoundException; {:try_start_2 .. :try_end_2} :catch_4

    .line 253
    invoke-static {v6}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    move-object v5, v6

    .end local v6           #objis:Ljava/io/ObjectInputStream;
    .restart local v5       #objis:Ljava/io/ObjectInputStream;
    move-object v1, v2

    .line 255
    .end local v2           #cached:Ljava/io/InputStream;
    .end local v7           #userAccount:Ljava/lang/Object;
    .end local v8           #usrAccount:Lcom/burstly/lib/currency/UserAccount;
    .restart local v1       #cached:Ljava/io/InputStream;
    :goto_0
    return-object v8

    .line 243
    :catch_0
    move-exception v9

    .line 253
    :goto_1
    invoke-static {v5}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    .line 255
    :goto_2
    const/4 v8, 0x0

    goto :goto_0

    .line 246
    :catch_1
    move-exception v4

    .line 247
    .local v4, ioe:Ljava/io/IOException;
    :goto_3
    :try_start_3
    sget-object v9, Lcom/burstly/lib/currency/UserAccountStorage;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "CurrencyManager"

    const-string v11, "Error occured while loading {0} user account!"

    const/4 v12, 0x1

    new-array v12, v12, [Ljava/lang/Object;

    const/4 v13, 0x0

    aput-object p1, v12, v13

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 253
    invoke-static {v5}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    goto :goto_2

    .line 249
    .end local v4           #ioe:Ljava/io/IOException;
    :catch_2
    move-exception v3

    .line 250
    .local v3, cnfe:Ljava/lang/ClassNotFoundException;
    :goto_4
    :try_start_4
    sget-object v9, Lcom/burstly/lib/currency/UserAccountStorage;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "CurrencyManager"

    const-string v11, "Could not load UserAccount class!"

    const/4 v12, 0x0

    new-array v12, v12, [Ljava/lang/Object;

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    .line 253
    invoke-static {v5}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    goto :goto_2

    .end local v3           #cnfe:Ljava/lang/ClassNotFoundException;
    :catchall_0
    move-exception v9

    :goto_5
    invoke-static {v5}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    throw v9

    .end local v1           #cached:Ljava/io/InputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    :catchall_1
    move-exception v9

    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_5

    .end local v1           #cached:Ljava/io/InputStream;
    .end local v5           #objis:Ljava/io/ObjectInputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    .restart local v6       #objis:Ljava/io/ObjectInputStream;
    :catchall_2
    move-exception v9

    move-object v5, v6

    .end local v6           #objis:Ljava/io/ObjectInputStream;
    .restart local v5       #objis:Ljava/io/ObjectInputStream;
    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_5

    .line 249
    .end local v1           #cached:Ljava/io/InputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    :catch_3
    move-exception v3

    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_4

    .end local v1           #cached:Ljava/io/InputStream;
    .end local v5           #objis:Ljava/io/ObjectInputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    .restart local v6       #objis:Ljava/io/ObjectInputStream;
    :catch_4
    move-exception v3

    move-object v5, v6

    .end local v6           #objis:Ljava/io/ObjectInputStream;
    .restart local v5       #objis:Ljava/io/ObjectInputStream;
    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_4

    .line 246
    .end local v1           #cached:Ljava/io/InputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    :catch_5
    move-exception v4

    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_3

    .end local v1           #cached:Ljava/io/InputStream;
    .end local v5           #objis:Ljava/io/ObjectInputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    .restart local v6       #objis:Ljava/io/ObjectInputStream;
    :catch_6
    move-exception v4

    move-object v5, v6

    .end local v6           #objis:Ljava/io/ObjectInputStream;
    .restart local v5       #objis:Ljava/io/ObjectInputStream;
    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_3

    .line 243
    .end local v1           #cached:Ljava/io/InputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    :catch_7
    move-exception v9

    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_1

    .end local v1           #cached:Ljava/io/InputStream;
    .end local v5           #objis:Ljava/io/ObjectInputStream;
    .restart local v2       #cached:Ljava/io/InputStream;
    .restart local v6       #objis:Ljava/io/ObjectInputStream;
    :catch_8
    move-exception v9

    move-object v5, v6

    .end local v6           #objis:Ljava/io/ObjectInputStream;
    .restart local v5       #objis:Ljava/io/ObjectInputStream;
    move-object v1, v2

    .end local v2           #cached:Ljava/io/InputStream;
    .restart local v1       #cached:Ljava/io/InputStream;
    goto :goto_1
.end method


# virtual methods
.method public clearStorage(Ljava/lang/String;)V
    .locals 7
    .parameter "cacheFileName"

    .prologue
    .line 179
    :try_start_0
    sget-object v1, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->lock()V

    .line 180
    new-instance v0, Ljava/io/File;

    sget-object v1, Lcom/burstly/lib/currency/UserAccountStorage;->sCacheDir:Ljava/io/File;

    invoke-direct {v0, v1, p1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 181
    .local v0, cache:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v1

    if-eqz v1, :cond_0

    invoke-virtual {v0}, Ljava/io/File;->delete()Z

    move-result v1

    if-nez v1, :cond_1

    .line 182
    :cond_0
    sget-object v1, Lcom/burstly/lib/currency/UserAccountStorage;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "CurrencyManager"

    const-string v3, "Failed to delete user account data file {0}"

    const/4 v4, 0x1

    new-array v4, v4, [Ljava/lang/Object;

    const/4 v5, 0x0

    invoke-virtual {v0}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v6

    aput-object v6, v4, v5

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 186
    :cond_1
    sget-object v1, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->unlock()V

    .line 188
    return-void

    .line 186
    .end local v0           #cache:Ljava/io/File;
    :catchall_0
    move-exception v1

    sget-object v2, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v2}, Ljava/util/concurrent/locks/Lock;->unlock()V

    throw v1
.end method

.method getAccount(Lcom/burstly/lib/currency/AccountInfo;Z)Lcom/burstly/lib/currency/UserAccount;
    .locals 5
    .parameter "accountInfo"
    .parameter "createIfNew"

    .prologue
    .line 107
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getUserId()Ljava/lang/String;

    move-result-object v3

    .line 108
    .local v3, userId:Ljava/lang/String;
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getPubId()Ljava/lang/String;

    move-result-object v2

    .line 109
    .local v2, pubId:Ljava/lang/String;
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v4, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 110
    .local v1, key:Ljava/lang/String;
    iget-object v4, p0, Lcom/burstly/lib/currency/UserAccountStorage;->mAccountCache:Ljava/util/Map;

    invoke-interface {v4, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/burstly/lib/currency/UserAccount;

    .line 111
    .local v0, account:Lcom/burstly/lib/currency/UserAccount;
    if-nez v0, :cond_1

    .line 112
    invoke-direct {p0, p1}, Lcom/burstly/lib/currency/UserAccountStorage;->loadAccount(Lcom/burstly/lib/currency/AccountInfo;)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 113
    if-eqz p2, :cond_0

    if-nez v0, :cond_0

    .line 114
    invoke-static {p1}, Lcom/burstly/lib/currency/UserAccountStorage;->createAccount(Lcom/burstly/lib/currency/AccountInfo;)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 116
    :cond_0
    iget-object v4, p0, Lcom/burstly/lib/currency/UserAccountStorage;->mAccountCache:Ljava/util/Map;

    invoke-interface {v4, v1, v0}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 118
    :cond_1
    return-object v0
.end method

.method getAllAccounts()Ljava/util/List;
    .locals 7
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Lcom/burstly/lib/currency/UserAccount;",
            ">;"
        }
    .end annotation

    .prologue
    .line 142
    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    .line 143
    .local v1, accounts:Ljava/util/List;,"Ljava/util/List<Lcom/burstly/lib/currency/UserAccount;>;"
    const/4 v0, 0x0

    .line 144
    .local v0, account:Lcom/burstly/lib/currency/UserAccount;
    sget-object v6, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v6}, Ljava/util/concurrent/locks/Lock;->lock()V

    .line 145
    sget-object v6, Lcom/burstly/lib/currency/UserAccountStorage;->sCacheDir:Ljava/io/File;

    invoke-virtual {v6}, Ljava/io/File;->listFiles()[Ljava/io/File;

    move-result-object v2

    .local v2, arr$:[Ljava/io/File;
    array-length v5, v2

    .local v5, len$:I
    const/4 v4, 0x0

    .local v4, i$:I
    :goto_0
    if-ge v4, v5, :cond_1

    aget-object v3, v2, v4

    .line 146
    .local v3, cached:Ljava/io/File;
    invoke-direct {p0, v3}, Lcom/burstly/lib/currency/UserAccountStorage;->readFile(Ljava/io/File;)Lcom/burstly/lib/currency/UserAccount;

    move-result-object v0

    .line 147
    if-eqz v0, :cond_0

    .line 148
    invoke-interface {v1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 145
    :cond_0
    add-int/lit8 v4, v4, 0x1

    goto :goto_0

    .line 151
    .end local v3           #cached:Ljava/io/File;
    :cond_1
    sget-object v6, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v6}, Ljava/util/concurrent/locks/Lock;->unlock()V

    .line 152
    return-object v1
.end method

.method getCachedFileList()[Ljava/lang/String;
    .locals 2

    .prologue
    .line 128
    :try_start_0
    sget-object v0, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->lock()V

    .line 129
    sget-object v0, Lcom/burstly/lib/currency/UserAccountStorage;->sCacheDir:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->list()[Ljava/lang/String;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result-object v0

    .line 132
    sget-object v1, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->unlock()V

    return-object v0

    :catchall_0
    move-exception v0

    sget-object v1, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->unlock()V

    throw v0
.end method

.method hasCachedFiles(Lcom/burstly/lib/currency/AccountInfo;)Z
    .locals 3
    .parameter "accInfo"

    .prologue
    .line 197
    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getUserId()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {p1}, Lcom/burstly/lib/currency/AccountInfo;->getPubId()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/burstly/lib/currency/UserAccountStorage;->createFileName(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 199
    .local v0, fileName:Ljava/lang/String;
    :try_start_0
    sget-object v1, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v1}, Ljava/util/concurrent/locks/Lock;->lock()V

    .line 200
    new-instance v1, Ljava/io/File;

    sget-object v2, Lcom/burstly/lib/currency/UserAccountStorage;->sCacheDir:Ljava/io/File;

    invoke-direct {v1, v2, v0}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/io/File;->exists()Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result v1

    .line 203
    sget-object v2, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v2}, Ljava/util/concurrent/locks/Lock;->unlock()V

    return v1

    :catchall_0
    move-exception v1

    sget-object v2, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v2}, Ljava/util/concurrent/locks/Lock;->unlock()V

    throw v1
.end method

.method public saveAccount(Lcom/burstly/lib/currency/UserAccount;)V
    .locals 10
    .parameter "userAccount"

    .prologue
    .line 276
    const/4 v2, 0x0

    .line 278
    .local v2, objoos:Ljava/io/ObjectOutputStream;
    :try_start_0
    sget-object v5, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v5}, Ljava/util/concurrent/locks/Lock;->lock()V

    .line 279
    invoke-virtual {p1}, Lcom/burstly/lib/currency/UserAccount;->getCacheFilename()Ljava/lang/String;

    move-result-object v0

    .line 280
    .local v0, fileName:Ljava/lang/String;
    if-nez v0, :cond_0

    .line 281
    invoke-virtual {p1}, Lcom/burstly/lib/currency/UserAccount;->getUserId()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {p1}, Lcom/burstly/lib/currency/UserAccount;->getPubId()Ljava/lang/String;

    move-result-object v6

    invoke-static {v5, v6}, Lcom/burstly/lib/currency/UserAccountStorage;->createFileName(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 282
    invoke-virtual {p1, v0}, Lcom/burstly/lib/currency/UserAccount;->setCacheFilename(Ljava/lang/String;)V

    .line 284
    :cond_0
    new-instance v4, Ljava/io/BufferedOutputStream;

    new-instance v5, Ljava/io/FileOutputStream;

    new-instance v6, Ljava/io/File;

    sget-object v7, Lcom/burstly/lib/currency/UserAccountStorage;->sCacheDir:Ljava/io/File;

    invoke-direct {v6, v7, v0}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    invoke-direct {v5, v6}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    invoke-direct {v4, v5}, Ljava/io/BufferedOutputStream;-><init>(Ljava/io/OutputStream;)V

    .line 285
    .local v4, output:Ljava/io/OutputStream;
    new-instance v3, Ljava/io/ObjectOutputStream;

    invoke-direct {v3, v4}, Ljava/io/ObjectOutputStream;-><init>(Ljava/io/OutputStream;)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 286
    .end local v2           #objoos:Ljava/io/ObjectOutputStream;
    .local v3, objoos:Ljava/io/ObjectOutputStream;
    :try_start_1
    invoke-virtual {v3, p1}, Ljava/io/ObjectOutputStream;->writeObject(Ljava/lang/Object;)V

    .line 287
    sget-object v5, Lcom/burstly/lib/currency/UserAccountStorage;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v6, "CurrencyManager"

    const-string v7, "User account: {0} has been successfully written to file."

    const/4 v8, 0x1

    new-array v8, v8, [Ljava/lang/Object;

    const/4 v9, 0x0

    aput-object p1, v8, v9

    invoke-virtual {v5, v6, v7, v8}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1

    .line 293
    invoke-static {v3}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    .line 294
    sget-object v5, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v5}, Ljava/util/concurrent/locks/Lock;->unlock()V

    move-object v2, v3

    .line 296
    .end local v0           #fileName:Ljava/lang/String;
    .end local v3           #objoos:Ljava/io/ObjectOutputStream;
    .end local v4           #output:Ljava/io/OutputStream;
    .restart local v2       #objoos:Ljava/io/ObjectOutputStream;
    :goto_0
    return-void

    .line 289
    :catch_0
    move-exception v1

    .line 290
    .local v1, ioe:Ljava/io/IOException;
    :goto_1
    :try_start_2
    sget-object v5, Lcom/burstly/lib/currency/UserAccountStorage;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v6, "CurrencyManager"

    const-string v7, "Error occured while saving response!"

    const/4 v8, 0x0

    new-array v8, v8, [Ljava/lang/Object;

    invoke-virtual {v5, v6, v7, v8}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 293
    invoke-static {v2}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    .line 294
    sget-object v5, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v5}, Ljava/util/concurrent/locks/Lock;->unlock()V

    goto :goto_0

    .line 293
    .end local v1           #ioe:Ljava/io/IOException;
    :catchall_0
    move-exception v5

    :goto_2
    invoke-static {v2}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    .line 294
    sget-object v6, Lcom/burstly/lib/currency/UserAccountStorage;->LOCK:Ljava/util/concurrent/locks/Lock;

    invoke-interface {v6}, Ljava/util/concurrent/locks/Lock;->unlock()V

    throw v5

    .line 293
    .end local v2           #objoos:Ljava/io/ObjectOutputStream;
    .restart local v0       #fileName:Ljava/lang/String;
    .restart local v3       #objoos:Ljava/io/ObjectOutputStream;
    .restart local v4       #output:Ljava/io/OutputStream;
    :catchall_1
    move-exception v5

    move-object v2, v3

    .end local v3           #objoos:Ljava/io/ObjectOutputStream;
    .restart local v2       #objoos:Ljava/io/ObjectOutputStream;
    goto :goto_2

    .line 289
    .end local v2           #objoos:Ljava/io/ObjectOutputStream;
    .restart local v3       #objoos:Ljava/io/ObjectOutputStream;
    :catch_1
    move-exception v1

    move-object v2, v3

    .end local v3           #objoos:Ljava/io/ObjectOutputStream;
    .restart local v2       #objoos:Ljava/io/ObjectOutputStream;
    goto :goto_1
.end method
